var list = [{
	id: '1',
	children: [{
		id: '11',
		children: [{
			id: '111'
		}, {
			id: '112'
		}]
	}, {
		id: '12',
		children: [{
			id: '121'
		}, {
			id: '122'
		}]
	}]
}]

/**
 * 深度优先遍历
 * 
 * @param {*} list 
 */
const dfs = (list) => {
    const stack = [];
    const ids = [];

    list.forEach(item => {
        stack.push(item);
    })

    while (stack.length) {
        const current = stack.pop();
        ids.push(current.id);

        if (current.children) {
            current.children.forEach(item => {
                stack.push(item);
            })
        }
    }

    return ids;
}

console.log(dfs(list));